﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Mvc;
using Coralcode.MvcBase.Client.Controllers;
using CoralNode.Core.Entity.Domains.Node;
using CoralNode.Core.IService.Node;

namespace Gongfu.Controllers
{
    public class VoteController : MvcControllerBase
    {
        private readonly INodeManageService _nodeService;

        public VoteController(INodeManageService nodeService)
        {
            _nodeService = nodeService;
        }
        [HttpPost]
        public ActionResult AddRank(long id)
        {
            var node = _nodeService.FindNode(id);
            node.Rank++;
            node.Update();
            var currentNode = _nodeService.FindNode(id);
            if (currentNode.Rank == node.Rank)
            {
                return Content(node.Rank.ToString());
            }
            return Content("0");
        }
    }
}